package com.java.demo.controller;

import com.java.demo.enity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;

@Controller
public class UserController {

    @Autowired
    private User user;

    public void printUser() {
        System.out.println(user);

        //修改user
        User myUser = user;
        myUser.setName("悟空");
        System.out.println("myUser - >" + myUser);
        System.out.println("user ->" +user); //悟空 -> 两个变量指向了同一个引用


    }

    @PostConstruct
    public void doPostConstruct() {
        System.out.println(user.toString());
        System.out.println("初始化");
    }
}
